﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DocumentManagement.ViewsModels;
using DocumentManagement.Models;


namespace DocumentManagement.Views
{
    /// <summary>
    /// Interaction logic for ShowItemDocumentOutUserControl.xaml
    /// </summary>
    public partial class ShowItemDocumentOutUserControl //: UserControl, ITabbedMDI
    {
        ShowItemDocumentOutViewsModel _showItemDocumentOutViewsModel;
        public ShowItemDocumentOutUserControl()
        {
            InitializeComponent();
            _showItemDocumentOutViewsModel = this.Resources["showItemDocumentOutViewsModel"] as ShowItemDocumentOutViewsModel;
        }

        private void DG_Hyperlink_Click(object sender, RoutedEventArgs e)
        {
            ShowItemFileOut showFile = new ShowItemFileOut(_showItemDocumentOutViewsModel.MySelectedEditItemSend);
            showFile.ShowDialog();
        }

        private void SendCodeOrTitleTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            _showItemDocumentOutViewsModel.Filter(SendCodeOrTitleTextBox.Text, FromDatePicker.SelectedDate, ToDatePicker.SelectedDate);
        }

        private void FromDatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            _showItemDocumentOutViewsModel.Filter(SendCodeOrTitleTextBox.Text, FromDatePicker.SelectedDate, ToDatePicker.SelectedDate);
        }

        private void ToDatePicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            _showItemDocumentOutViewsModel.Filter(SendCodeOrTitleTextBox.Text, FromDatePicker.SelectedDate, ToDatePicker.SelectedDate);
        }

      
        private void addOUTDocMenu_Click(object sender, RoutedEventArgs e)
        {
            AddDocumentOut addWin = new AddDocumentOut(new CreateSend { CreateSendDate = DateTime.Now }, _showItemDocumentOutViewsModel.EntityModels);
            addWin.ShowDialog();
            addWin.Unloaded += (s, args) =>
                {
                    _showItemDocumentOutViewsModel.RefreshData();
                };
        }

        private void editOUTDocMenu_Click(object sender, RoutedEventArgs e)
        {
            AddDocumentOut addWin = new AddDocumentOut(_showItemDocumentOutViewsModel.MySelectedEditItemSend, _showItemDocumentOutViewsModel.EntityModels);
            addWin.ShowDialog();
        }

        private void deleteOUTDocMenu_Click(object sender, RoutedEventArgs e)
        {
            _showItemDocumentOutViewsModel.DeleteFromDatabase();
        }

        //private void CreateOUTDocMenu_Click(object sender, RoutedEventArgs e)
        //{
        //    OptionDocument addWin = new OptionDocument(new CreateSend { CreateSendDate = DateTime.Now }, _showItemDocumentOutViewsModel.EntityModels);
        //    addWin.ShowDialog();
        //}

       

       
    }
}
